const mongoose = require('mongoose')
const model = mongoose.model.bind(mongoose)
const Schema = mongoose.Schema
const ObjectId = Schema.Types.ObjectId

const iproductSchema = new Schema({
   _id: ObjectId,
   label: String,
   price: String,
   num: Number,
   created_time: {
    type: Date,
    default: new Date().getTime() 
   },
   ords:[{
    type:ObjectId,
    ref:'Ording'
   }]
})

const ordingSchema = new Schema({
    _id:ObjectId,
    ordId:String,
    price: String,
    is_paid: {
      type:Boolean,
      default: false
    },
    is_send: {
        type:Boolean,
        default: false
      },
    created_time: {
      type: Date,
      default: new Date().getTime()
    }
})



const Iproduct = model('Iproduct', iproductSchema )
const Ording = model('Ording', ordingSchema )


module.exports =  { Iproduct, Ording }